home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / windows2 / hp22d3.zip / REFGUIDE / CHUNKEX.TXT < prev    next >
Text File  |  1991-05-16  |  7KB  |  214 lines

  1.  
  2.  
  3.  
  4.  
  5.     ________________________________________________________________________
  6.                                        Chapter 7: Chunk Expressions   59
  7.     ________________________________________________________________________
  8.  
  9.  
  10.     CHAPTER SEVEN: CHUNK EXPRESSIONS
  11.  
  12.     In an English-like intuitive manner, chunking precisely accesses any
  13.     piece of data from anywhere within your pad. You can specify individual
  14.     or groups of characters, words, items or lines from a container, or even
  15.     pinpoint parts of other chunks. The following are examples of chunking
  16.     used to access information:
  17.  
  18.     put char 1 of page field 1 into msg;
  19.  
  20.     print the last word of field "Last Name";
  21.  
  22.     delete the first line of MyWordList;
  23.  
  24.  
  25.     SIMPLE CHUNK EXPRESSIONS
  26.  
  27.     There are three forms of a simple chunk expression. These examples show
  28.     each form using character (abbreviated char) chunks.
  29.  
  30.     The first form specifies any character within the container, in this
  31.     case the first character.
  32.  
  33.     char 1 of page field 1
  34.  
  35.     The second form specifies a range of characters (a group) within the
  36.     container, in this case the first 10 characters.
  37.  
  38.     char 1 to 10 of page field 1
  39.  
  40.     The last uses an ordinal to specify the character within the container,
  41.     in this case, the third character.
  42.  
  43.     the third character of page field 1
  44.  
  45.  
  46.  
  47.     ________________________________________________________________________
  48.                                        Chapter 7: Chunk Expressions   60
  49.     ________________________________________________________________________
  50.  
  51.  
  52.     The available ordinals are:
  53.  
  54.     Ordinal:        Example Chunk:
  55.     ------------------------------------------------------------
  56.     first           the first character of field 1
  57.  
  58.     second          the second character of field 1
  59.  
  60.     third           the third character of field 1
  61.  
  62.     fourth          the fourth character of field 1
  63.  
  64.     fifth           the fifth character of field 1
  65.  
  66.     sixth           the sixth character of field 1
  67.  
  68.     seventh         the seventh character of field 1
  69.  
  70.     eight           the eight character of field 1
  71.  
  72.     ninth           the ninth character of field 1
  73.  
  74.     tenth           the tenth character of field 1
  75.  
  76.     any             any character of field 1
  77.  
  78.     middle          the middle character of field 1
  79.  
  80.     last            the last character of field 1
  81.  
  82.  
  83.     The special ordinals any, middle, and last depend on the contents of the
  84.     container. The ordinal any specifies a random character, word, item, or
  85.     line, and middle selects the middle character, word, item, or line.
  86.  
  87.  
  88.     CHARACTER CHUNKS
  89.  
  90.     Character chunks are determined by offsets within the container. The
  91.     following example returns the character at position 5 ("o").
  92.  
  93.     char 5 of "hello there"
  94.  
  95.     All characters, including spaces and carriage returns, are treated as
  96.     chunking characters.
  97.  
  98.  
  99.     WORD CHUNKS
  100.  
  101.     Word chunks are delimited by spaces (" ") or carriage returns. For
  102.     example,
  103.  
  104.  
  105.  
  106.     ________________________________________________________________________
  107.                                        Chapter 7: Chunk Expressions   61
  108.     ________________________________________________________________________
  109.     word 2 of "this is a test"
  110.  
  111.     will return the word "is". Notice that the word itself is returned
  112.     stripped of any spaces or carriage returns that surround it.
  113.  
  114.  
  115.  
  116.     ________________________________________________________________________
  117.                                        Chapter 7: Chunk Expressions   62
  118.     ________________________________________________________________________
  119.  
  120.  
  121.     ITEM CHUNKS
  122.  
  123.     Item chunks are delimited by commas (","). For example,
  124.  
  125.     item 2 of "doctor,lawyer,clerk,"
  126.  
  127.     will return "lawyer". In fact, the text between the first and second
  128.     comma is returned, even if there are spaces and many words. For example,
  129.  
  130.     item 2 of "doctor Williams  ,lawyer Seeley  ,clerk Betty"
  131.     will return "lawyer Seeley  ". Notice that the commas are not returned.
  132.  
  133.  
  134.     LINE CHUNKS
  135.  
  136.     Line chunks are delimited by carriage returns. For example, if there is
  137.     a field with the following text:
  138.  
  139.     doctor Williams
  140.     lawyer Seeley
  141.     clerk Betty
  142.  
  143.     the following chunk expression
  144.  
  145.     line 2 of field 1
  146.  
  147.     will return "lawyer Seeley". Like item chunks, anything between the
  148.     carriage returns is returned, including spaces, words and items. Since
  149.     the text in fields may be word wrapped, the actual number of lines in a
  150.     field and the number of lines on the screen may not always be the same.
  151.     Also, line chunks are returned without their carriage return delimiters.
  152.  
  153.  
  154.     SPECIFYING CHUNKS OF CHUNKS
  155.  
  156.     In addition to simple chunking expressions, combine chunking types to
  157.     further pinpoint a piece of text. Always order the statement from the
  158.     smallest chunk to the largest chunk. Each chunk type is separated by the
  159.     word of. For example:
  160.  
  161.     char 1 of word 6 of page field 1
  162.  
  163.     char 5 to 8 of the second item of field "Address"
  164.  
  165.     char 1 of word 2 of item 6 of the last line of field 1 of
  166.     page 10
  167.  
  168.     the middle item of any line of field "Zippy Messages"
  169.  
  170.  
  171.  
  172.     ________________________________________________________________________
  173.                                        Chapter 7: Chunk Expressions   63
  174.     ________________________________________________________________________
  175.  
  176.  
  177.     CHUNKING DESTINATIONS
  178.  
  179.     In addition to retrieving pieces of text, you can use chunk expressions
  180.     as destinations for text. For example:
  181.  
  182.     put "hello" into word 6 of page field 1;
  183.     put pg fld 2 before the first line of pg fld 1;
  184.  
  185.     When pinpointing a chunk as a destination, specify if you want to
  186.     replace the chunk (by using into), insert before the chunk (by using
  187.     before) or insert after the chunk (by using after).
  188.  
  189.     If you use into, the expression supplied will replace the specified
  190.     destination chunk. For example, if field 1 contains "HyperPAD", then the
  191.     command:
  192.  
  193.     put "Extension" into char 6 to 8 of "HyperPAD"
  194.  
  195.     will change field 1 to "HyperExtension".
  196.  
  197.     If you specify a non-existent item as the destination, HyperPAD will
  198.     create blank items as filler. For example, suppose field 1 contains
  199.     "John Smith", then the following statement
  200.  
  201.     put "Sue" into item 4 of field 1;
  202.  
  203.     will change field 1 to "John Smith,,,Sue". Notice that HyperPAD inserted
  204.     3 commas in order to make "Sue" the fourth item. The same will happen
  205.     for line chunks as well.
  206.  
  207.     Using before and after as destinations with items and lines inserts a
  208.     delimiter. For example, the following statement
  209.  
  210.     put "Hello There" after the last line of page field 1;
  211.  
  212.     appends a line after page field 1 and sets it to "Hello There". HyperPAD
  213.     inserts a carriage return to create the correct number of lines. The
  214.     same is true of items.